package com.xk.springboot.pojo;



import com.xk.springboot.flag.Login;
import com.xk.springboot.flag.Register;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

/**
 * @author:Teacher黄
 * @date:Created at 2020/04/08
 * 分组校验的步骤:
 *  1. 创建分组标记  (登陆标记和注册标记)
 *  2. 在对应实体规则的地方去指定标记
 *  3. 验证的时候指定标记
 */
public class Member {

    private Integer id;

    @NotBlank(message = "会员名字不能为空",groups = {Register.class, Login.class})
    private String memberName;

    @NotBlank(message = "密码不能为空!",groups = {Register.class, Login.class})
    @Pattern(regexp = "^\\w{6,8}$",message = "密码格式不正确!", groups = {Register.class, Login.class})
    private String memberPwd;

    @NotBlank(message = "会员地址不能为空!",groups = Register.class)
    private String memberAddress;

    private Integer memberAge;

    public Member() {
    }

    public Member(@NotBlank(message = "会员名字不能为空", groups = {Register.class, Login.class}) String memberName, @NotBlank(message = "会员地址不能为空!", groups = Register.class) String memberAddress, Integer memberAge) {
        this.memberName = memberName;
        this.memberAddress = memberAddress;
        this.memberAge = memberAge;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getMemberName() {
        return memberName;
    }

    public void setMemberName(String memberName) {
        this.memberName = memberName;
    }

    public String getMemberPwd() {
        return memberPwd;
    }

    public void setMemberPwd(String memberPwd) {
        this.memberPwd = memberPwd;
    }

    public Integer getMemberAge() {
        return memberAge;
    }

    public void setMemberAge(Integer memberAge) {
        this.memberAge = memberAge;
    }

    public String getMemberAddress() {
        return memberAddress;
    }

    public void setMemberAddress(String memberAddress) {
        this.memberAddress = memberAddress;
    }

    @Override
    public String toString() {
        return "Member{" +
                "id=" + id +
                ", memberName='" + memberName + '\'' +
                ", memberPwd='" + memberPwd + '\'' +
                ", memberAge=" + memberAge +
                '}';
    }
}
